import mysql from 'mysql2/promise'

// 创建连接池，设置连接池的参数
const pool = mysql.createPool({
  host: 'rm-cn-bl03pb66m000y28o.rwlb.rds.aliyuncs.com',
  port: 3306,
  user: 'root',
  password: 'ScK4D4^6^^j*bD2k',
  database: 'xiuxian',
  waitForConnections: true,
  connectionLimit: 10,
  maxIdle: 10, // 最大空闲连接数，默认值与“connectionLimit”相同
  idleTimeout: 60000, // 空闲连接超时时间，单位毫秒，默认值60000
  queueLimit: 0,
  enableKeepAlive: true,
  keepAliveInitialDelay: 0,
})

async function main() {
  try {
    const [rows] = await pool.query('SELECT * FROM user WHERE username = ?', ['nvgyut'])
    console.log(rows)
  } catch (err) {
    console.log(err)
  }
}
